using HCore.IOC.Beans.Factory.Attribute.Attr;
using HCore.IOC.Context.Event;
using HCore.IOC.Context.Event.Attr;
using HCore.Tests.Runtime.DianDianDian.Event;
using HCore.Tests.Runtime.DianDianDian.Model;
using HCore.Tests.Runtime.ShootingEditor2D.Scripts.Support.CommandQuery;
using UnityEngine;

namespace HCore.Tests.Runtime.DianDianDian.Command
{
    public class KillEnemyCommand : ICommand
    {
    }

    [IOC.Context.Stereotype.Component]
    public class KillEnemyCommandEventSenderReceiver : EventPublisher
    {
        [Autowired] private IGameModel mGameModel;

        [EventListener]
        public void OnKillEnemyCommand(KillEnemyCommand command)
        {
            mGameModel.KillCount++;

            // 击杀，随机（0.33的概率）获得1~2的金币
            if (Random.Range(0, 10) < 3) mGameModel.Gold += Random.Range(1, 3);

            PublishEvent(new EnemyKillEvent());

            if (mGameModel.KillCount >= 10) PublishEvent(new GamePassEvent());
        }
    }
}